TODO = [
    [2, 1],
    [15, 10, 5, 3, 2, 1],
    [23, 13, 10, 5, 3, 2, 1],
    [27, 18, 9, 6, 3, 2, 1],
    [30, 15, 10, 5, 3, 2, 1],
    [31, 17, 14, 7, 4, 3, 2, 1],
    [39, 26, 13, 8, 5, 3, 2, 1],
    [43, 23, 20, 10, 5, 3, 2, 1],
    [45, 30, 15, 10, 5, 3, 2, 1],
    [46, 23, 13, 10, 5, 3, 2, 1],
    [47, 27, 20, 10, 7, 4, 3, 2, 1],
    [51, 27, 24, 12, 6, 3, 2, 1],
    [54, 27, 18, 9, 6, 3, 2, 1],
    [55, 33, 22, 11, 7, 4, 3, 2, 1],
    [59, 31, 28, 14, 7, 4, 3, 2, 1],
    [60, 30, 15, 10, 5, 3, 2, 1],
    [61, 33, 28, 14, 7, 5, 3, 2, 1],
    [62, 31, 17, 14, 7, 4, 3, 2, 1],
    [63, 42, 21, 14, 7, 4, 3, 2, 1],
    [75, 50, 25, 15, 10, 5, 3, 2, 1],
    [77, 41, 36, 18, 9, 5, 4, 2, 1],
    [78, 39, 26, 13, 8, 5, 3, 2, 1],
    [79, 43, 36, 18, 9, 7, 4, 3, 2, 1],
    [83, 43, 40, 20, 10, 5, 3, 2, 1],
    [85, 45, 40, 20, 10, 5, 3, 2, 1],
    [86, 43, 23, 20, 10, 5, 3, 2, 1],
    [87, 47, 40, 20, 10, 7, 4, 3, 2, 1],
    [90, 45, 30, 15, 10, 5, 3, 2, 1],
    [91, 47, 44, 22, 11, 7, 4, 3, 2, 1],
    [92, 46, 23, 13, 10, 5, 3, 2, 1],
    [93, 62, 31, 17, 14, 7, 4, 3, 2, 1],
    [94, 47, 27, 20, 10, 7, 4, 3, 2, 1],
    [95, 51, 44, 22, 11, 7, 4, 3, 2, 1],
    [99, 51, 48, 24, 12, 6, 3, 2, 1],
    [102, 51, 27, 24, 12, 6, 3, 2, 1],
    [103, 55, 48, 24, 12, 7, 5, 3, 2, 1],
    [107, 55, 52, 26, 13, 8, 5, 3, 2, 1],
    [108, 54, 27, 18, 9, 6, 3, 2, 1],
    [109, 57, 52, 26, 13, 8, 5, 3, 2, 1],
    [110, 55, 33, 22, 11, 7, 4, 3, 2, 1],
    [111, 74, 37, 21, 16, 8, 5, 3, 2, 1],
    [115, 59, 56, 28, 14, 7, 4, 3, 2, 1],
    [117, 61, 56, 28, 14, 7, 5, 3, 2, 1],
    [118, 59, 31, 28, 14, 7, 4, 3, 2, 1],
    [119, 63, 56, 28, 14, 7, 4, 3, 2, 1],
    [120, 60, 30, 15, 10, 5, 3, 2, 1],
    [121, 61, 60, 30, 15, 10, 5, 3, 2, 1],
    [122, 61, 33, 28, 14, 7, 5, 3, 2, 1],
    [123, 63, 60, 30, 15, 10, 5, 3, 2, 1],
    [124, 62, 31, 17, 14, 7, 4, 3, 2, 1],
    [125, 75, 50, 25, 15, 10, 5, 3, 2, 1],
    [126, 63, 42, 21, 14, 7, 4, 3, 2, 1],
    [135, 90, 45, 30, 15, 10, 5, 3, 2, 1],
    [147, 75, 72, 36, 18, 9, 6, 3, 2, 1],
    [149, 77, 72, 36, 18, 9, 5, 4, 2, 1],
    [150, 75, 50, 25, 15, 10, 5, 3, 2, 1],
    [153, 81, 72, 36, 18, 9, 6, 3, 2, 1],
    [154, 77, 41, 36, 18, 9, 5, 4, 2, 1],
    [156, 78, 39, 26, 13, 8, 5, 3, 2, 1],
    [163, 83, 80, 40, 20, 10, 5, 3, 2, 1],
    [165, 85, 80, 40, 20, 10, 5, 3, 2, 1],
    [166, 83, 43, 40, 20, 10, 5, 3, 2, 1],
    [170, 85, 45, 40, 20, 10, 5, 3, 2, 1],
    [172, 86, 43, 23, 20, 10, 5, 3, 2, 1],
    [180, 90, 45, 30, 15, 10, 5, 3, 2, 1],
    [184, 92, 46, 23, 13, 10, 5, 3, 2, 1],
    [195, 99, 96, 48, 24, 12, 6, 3, 2, 1],
    [198, 99, 51, 48, 24, 12, 6, 3, 2, 1],
    [204, 102, 51, 27, 24, 12, 6, 3, 2, 1],
    [216, 108, 54, 27, 18, 9, 6, 3, 2, 1],
    [240, 120, 60, 30, 15, 10, 5, 3, 2, 1]
]

$ans = [-1] * 502

def gao(n, m)
    ret = [n]
    while n > 1 && ret.size < $ans.size
        (m - 1).downto(-1) do |i|
            if i == -1
                n -= 1
                ret.push(n)
            elsif n % TODO[i][0] == 0
                n /= TODO[i][0]
                ret.concat(TODO[i][1 .. -1].map{|_| _ * n})
            else
                next
            end
            break
        end
    end
    return ret
end

n = gets.to_i
# 1.upto(TODO.size) do |m|
[TODO.size].each do |m|
    tmp = gao(n, m)
    if tmp.size < $ans.size
        $ans = tmp
    end
end

h = {}
$ans = $ans.reverse
$ans.zip($ans.size.times){|i, j| h[i] = j}

p $ans.size - 1
1.upto($ans.size - 1) do |i|
    i.times do |j|
        if h.has_key?($ans[i] - $ans[j])
            puts "#{j} #{h[$ans[i] - $ans[j]]}"
            break
        end
    end
end
